﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO_HealthInsurance;
using BLL_HealthInsurance;
using DAO_HealthInsurance;

namespace HealthInsuranceMgm
{
    public partial class Memberlogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnlogin_Click(object sender, EventArgs e)
        {

            DAOSecurityPassword seccu = new DAOSecurityPassword();// khoi tao lai ham ma hoa ben DAO.
            string username = txtusername.Text;
            string password = txtpassword.Text;
            DTOEmployee objEmp = new DTOEmployee();
            BLLEmployee objBll = new BLLEmployee();


            if (username != "" && password != "")
            {
                objEmp.EmpUserName = username;
                objEmp.EmpPassword = seccu.EnCrypt(password).ToString() ;// ma hoa pass de so sanh vs pass trong database
                if (objBll.checkemplogin(objEmp) == true)
                {
                    Session["username"] = txtusername.Text;
                    Session["password"] = txtpassword.Text;
                    Session["empno"]=
                    Session["permission"] = "emp";
                    Session.Timeout = 10000;
                    Response.Redirect("/Admin/MemberFunction.aspx");

                }
                else
                {
                    lblthongbao.Text = "UserName Or Password not Match!";
                    Response.Write(password);
                  
                }
            }
            else
            {
                lblthongbao.Text = "Sorry! Username or Password not Empty!";
            }
        }
    }
}